import { cloud, default as request } from '@/framework/utils/request'

export function login(data) {
  return request({
    url: `${cloud.auth}/loginApi`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getInfo(token) {
  return request({
    url: `${cloud.auth}/getCurrentLoginUserInfo/V2`,
    method: 'get',
    params: { token }
  })
}

export function getUserInfo() {
  return request({
    url: `${cloud.dqbasic}/sysUser/currentUserInfo`,
    method: 'get'
  })
}

export function logout() {
  return request({
    url: `${cloud.auth}/logoutAction`,
    method: 'post'
  })
}

export function getAuthentication() {
  return request({
    url: `${cloud.auth}/authentication/info`,
    method: 'get'
  })
}

// 图片校验
export function getcaptch() {
  return request({
    url: `${cloud.auth}/captcha`,
    method: 'get'
  })
}

// 验证邮箱是否正确
export function tovalidatorEmai(params) {
  return request({
    url: `${cloud.auth}/sysUser/validatorEmail`,
    method: 'post',
    data: params
  })
}

// 找回密码-验证邮箱通过-发送邮箱验证码
export function getsendMailAuthCode(params) {
  return request({
    url: `${cloud.auth}/sysUser/sendMailAuthCode`,
    method: 'get',
    params
  })
}

// 找回密码-邮箱验证码校验 验证码重置密码合一接口
export function validatorEmailAuthCode(params) {
  return request({
    url: `${cloud.auth}/sysUser/validatorEmailAuthCode`,
    method: 'POST',
    data: params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 重置密码
export function resetPwdEmail(params) {
  return request({
    url: `${cloud.auth}/sysUser/resetPwdEmail`,
    method: 'POST',
    data: params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 单点账号密码登录
export function loginApi(data) {
  return request({
    url: `${cloud.auth}/sso/loginApi`,
    method: 'post',
    data
  })
}

export function loginWithToken(data) {
  return request({
    url: `${cloud.auth}/sso/loginWithToken`,
    method: 'post',
    data
  })
}

// 单点短信登录
export function loginSms(data) {
  return request({
    url: `${cloud.auth}/sso/loginSms`,
    method: 'post',
    data
  })
}

// 发送短信验证码
export function loginSendSms(data) {
  return request({
    url: `${cloud.usercenter}/sysUser/sendMailCode`,
    method: 'post',
    data
  })
}

// 因子2 发送短信验证码
export function twoAuthWaySendLoginSms(data) {
  return request({
    url: '/loginSms/twoAuthWaySendLoginSms',
    method: 'post',
    data
  })
}

// 短信验证码登录
export function loginBySms(data) {
  return request({
    url: `${cloud.auth}/loginBySms`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 账号密码登录
export function loginByPwd(data) {
  return request({
    url: `${cloud.auth}/loginApi`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 获取滑块验证码配置
export function getSliderKaptcha(data) {
  return request({
    url: `${cloud.auth}/kaptcha/getSliderKaptcha`,
    method: 'get'
  })
}

// 校验滑块验证码是否通过
export function checkSliderKaptcha(data) {
  return request({
    url: `${cloud.auth}/kaptcha/checkSliderKaptcha`,
    method: 'post',
    data
  })
}

// 滑块成功后点击下一步调用 发送验证码接口
export function sendMailCode(params) {
  return request({
    url: `${cloud.auth}/sysUser/sendMailCode`,
    method: 'POST',
    data: params
  })
}

// 获取认证规则配置
export function getAuthRules(data) {
  return request({
    url: `${cloud.auth}/authRules/getAuthRules`,
    method: 'get',
    params: data
  })
}

// 修改认证规则配置
export function updateAuthRules(data) {
  return request({
    url: `${cloud.auth}/authRules/updateAuthRules`,
    method: 'post',
    data
  })
}

// 获取租户选择先拉框的接口
export function getTenantDropDownList(data) {
  return request({
    url: `${cloud.tenant}/sysTenant/getTenantDropDownList`,
    method: 'get'
  })
}

// 首次登录强制修改密码
export function updatePwdNoToken(data) {
  return request({
    url: `${cloud.usercenter}/sysUser/updatePwdNoToken`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取短信验证码 /sendMsgCode
 * @param data
 */
export function getPhoneCode(data) {
  return request({
    url: `${cloud.mall}/sendMsgCode`,
    method: 'get',
    params: data
  })
}

/**
 * @description: 用户注册 /sysUserAdd
 * @param data
 */
export function userRegister(data) {
  return request({
    url: `${cloud.mall}/sysUserAdd`,
    method: 'post',
    data
  })
}

/**
 * @description: 在线学堂用户注册 /sysUserAdd
 * @param data
 */
export function onlineUserRegister(data) {
  return request({
    url: `${cloud.onlineClass}/userInfo/add`,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    method: 'post',
    data
  })
}

/**
 * @description: 在线学习平台验证规则 /qryPwdRule
 * @param data
 */
export function onlineQryPwdRule(data) {
  return request({
    url: `${cloud.onlineClass}/pwdRule/judge?password=` + data,
    method: 'get'
  })
}
/**
 * @description: 验证规则 /qryPwdRule
 * @param data
 */
export function qryPwdRule(data) {
  return request({
    url: `${cloud.mall}/qryPwdRule`,
    method: 'get',
    data
  })
}

/**
 * @description: 查询收货地址列表 /tMmsetReceivingAddress/pageList
 * @param data
 */
export function addressPageList(data) {
  return request({
    url: `${cloud.mall}/tMmsetReceivingAddress/pageList`,
    method: 'get',
    params: data
  })
}

/**
 * @description: 新增收货地址 /tMmsetReceivingAddress/insert
 * @param data
 */
export function addAddress(data) {
  return request({
    url: `${cloud.mall}/tMmsetReceivingAddress/insert`,
    method: 'post',
    data
  })
}

/**
 * @description: 更新地址 /tMmsetReceivingAddress/update
 * @param data
 */
export function updateAddress(data) {
  return request({
    url: `${cloud.mall}/tMmsetReceivingAddress/update`,
    method: 'post',
    data
  })
}

/**
 * @description: 删除 /tMmsetReceivingAddress/delete
 * @param data
 */
export function deleteAddress(data) {
  return request({
    url: `${cloud.mall}/tMmsetReceivingAddress/delete`,
    method: 'post',
    params: data
  })
}

/**
 * @description: 设为默认 /tMmsetReceivingAddress/edit/isDefault
 * @param data
 */
export function setDefault(data) {
  return request({
    url: `${cloud.mall}/tMmsetReceivingAddress/edit/isDefault`,
    method: 'post',
    params: data
  })
}

/**
 * @description: 商家入驻 /tMallInfo/openMall
 * @param data
 */

export function openMall(data) {
  return request({
    url: `${cloud.mall}/tMallInfo/openMall`,
    method: 'post',
    data
  })
}

/**
 * @description: 获取验证码 /tMallInfo/code
 * @param data
 */
export function getCode(data) {
  return request({
    url: `${cloud.mall}/tMallInfo/code`,
    method: 'get',
    params: data
  })
}
